package com.irdstudio.apicenter.gateway.web.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;

import com.irdstudio.apicenter.gateway.comm.MaccsPacket;
import com.irdstudio.apicenter.gateway.comm.MaccsPacketUtil;
import com.irdstudio.apicenter.gateway.core.jdbc.MaccsBaseDAO;
import com.irdstudio.apicenter.gateway.util.spring.BeanUtils;
import com.irdstudio.apicenter.gateway.web.MaccsException;
import com.irdstudio.apicenter.gateway.web.MaccsTradeDefineVo;
import com.irdstudio.apicenter.gateway.web.view.JsonView;
import com.irdstudio.apicenter.gateway.web.view.View;

/**
 * 返回广告轮播信息
 * 
 * @author zs.ligm
 * @version 1.0
 * @date 2015-09-21
 */
@Controller
public class AdRollInfo implements IController {

	/* 文本日志输出 */
	private static final Logger logger = LoggerFactory.getLogger(AdRollInfo.class);
	private static final String queryAppAdRollSql = "select * from app_ad_roll where app_id=? order by  record_key asc";

	@Override
	public View execute(MaccsTradeDefineVo tradeDefine, MaccsPacket inPacket, HttpServletRequest request,
			HttpServletResponse response) throws MaccsException {
		// TODO Auto-generated method stub
		String appId = inPacket.getValue("appId");
		// 获取APP用户数据权限
		MaccsBaseDAO jdbcDao = BeanUtils.getBean(MaccsBaseDAO.class);
		List<Map<String, Object>> AppAdRollList = jdbcDao.findMapList(queryAppAdRollSql, new Object[] { appId });
		MaccsPacket outPacket = MaccsPacketUtil.makeSimpleSuccessPacket("OK!");
		outPacket.addVariable("adRoll", AppAdRollList);
		return new JsonView(request, response, outPacket);
	}
}
